var api = require("./api_v1")

/* User page. */

userAll = {
  path: "/users",
  method: "get",
  executor: function(req, res, next) {
    model.User.findAll().then(users => {
      //  console.log("All users:", JSON.stringify(users, null, 4));
       res.send(users);
    });
  },
}
userCreate = {
  path: "/user",
  method: "post",
  executor: function(req, res, next) {
    model.User.create(req.body).then(user => {
      res.send(user.dataValues);
    }, err => {
      next(err);
    })
  }
}

router = {
  type: "router",
  locations: [
    userAll,
    userCreate,
  ]
}

module.exports = api.register(router)
